home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / OpenTransportProviders.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  50.5 KB  |  1,783 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        OpenTransportProviders.h
  3.  
  4.      Contains:    This file contains provider-specific definitions for various built-in providers.
  5.  
  6.      Version:    Technology:    2.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1993-1999 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OPENTRANSPORTPROVIDERS__
  18. #define __OPENTRANSPORTPROVIDERS__
  19.  
  20. #ifndef __OPENTRANSPORT__
  21.     #include <OpenTransport.h>
  22. #endif
  23.  
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47. #if defined(__MWERKS__) && TARGET_CPU_68K
  48.     #pragma push
  49.     #pragma pointers_in_D0
  50. #endif
  51.  
  52.  
  53. /* ***** TCP/IP ******/
  54.  
  55. /* Basic types*/
  56.  
  57. typedef UInt16                             InetPort;
  58. typedef UInt32                             InetHost;
  59. /*    Enums used as address type designations.*/
  60. #ifndef AF_INET /* might conflict with BSD headers */ 
  61. enum {
  62.     AF_INET                        = 2,                            /* Traditonal*/
  63.     AF_DNS                        = 42                            /* Obviously, the answer to...*/
  64. };
  65.  
  66. #else
  67. enum {
  68.     AF_DNS                = 42    // Obviously, the answer to...
  69. };
  70. #endif
  71. /*
  72.       Enum which can be used to bind to all IP interfaces
  73.       rather than a specific one.
  74. */
  75. enum {
  76.     kOTAnyInetAddress            = 0                                /* Wildcard*/
  77. };
  78.  
  79. /*
  80.    Define the InetSvcRef type.  This type needs special
  81.    processing because in C++ it's a subclass of TProvider.
  82.    See the definition of TEndpointRef in "OpenTransport.h"
  83.    for the logic behind this definition.
  84. */
  85.  
  86. #ifdef __cplusplus
  87.  typedef class TInternetServices*    InetSvcRef;
  88. #else
  89.  typedef void*                        InetSvcRef;
  90. #endif
  91. #define kDefaultInternetServicesPath        ((OTConfigurationRef)-3L)
  92. /* Shared library prefixes*/
  93.  
  94.  
  95. #define kInetVersion    "3.1.1"
  96. #define kInetPrefix        "ot:inet$"
  97.  
  98. /* Module Names*/
  99.  
  100.  
  101. #define kDNRName        "dnr"
  102. #define kTCPName        "tcp"
  103. #define kUDPName        "udp"
  104. #define kRawIPName        "rawip"
  105.  
  106. /* XTI Options*/
  107.  
  108. /* Protocol levels*/
  109.  
  110. enum {
  111.     INET_IP                        = 0x00,
  112.     INET_TCP                    = 0x06,
  113.     INET_UDP                    = 0x11
  114. };
  115.  
  116. /* TCP Level Options*/
  117.  
  118. enum {
  119.     TCP_NODELAY                    = 0x01,
  120.     TCP_MAXSEG                    = 0x02,
  121.     TCP_NOTIFY_THRESHOLD        = 0x10,                            /** not a real XTI option */
  122.     TCP_ABORT_THRESHOLD            = 0x11,                            /** not a real XTI option */
  123.     TCP_CONN_NOTIFY_THRESHOLD    = 0x12,                            /** not a real XTI option */
  124.     TCP_CONN_ABORT_THRESHOLD    = 0x13,                            /** not a real XTI option */
  125.     TCP_OOBINLINE                = 0x14,                            /** not a real XTI option */
  126.     TCP_URGENT_PTR_TYPE            = 0x15,                            /** not a real XTI option */
  127.     TCP_KEEPALIVE                = 0x0008                        /* keepalive defined in OpenTransport.h */
  128. };
  129.  
  130. enum {
  131.     T_GARBAGE                    = 2
  132. };
  133.  
  134. /* UDP Level Options*/
  135.  
  136. enum {
  137.     UDP_CHECKSUM                = 0x0600,
  138.     UDP_RX_ICMP                    = 0x02
  139. };
  140.  
  141. /* IP Level Options*/
  142. enum {
  143.     kIP_OPTIONS                    = 0x01,
  144.     kIP_TOS                        = 0x02,
  145.     kIP_TTL                        = 0x03,
  146.     kIP_REUSEADDR                = 0x04,
  147.     kIP_DONTROUTE                = 0x10,
  148.     kIP_BROADCAST                = 0x20,
  149.     kIP_REUSEPORT                = 0x0200,
  150.     kIP_HDRINCL                    = 0x1002,
  151.     kIP_RCVOPTS                    = 0x1005,
  152.     kIP_RCVDSTADDR                = 0x1007,
  153.     kIP_MULTICAST_IF            = 0x1010,                        /* set/get IP multicast interface    */
  154.     kIP_MULTICAST_TTL            = 0x1011,                        /* set/get IP multicast timetolive    */
  155.     kIP_MULTICAST_LOOP            = 0x1012,                        /* set/get IP multicast loopback    */
  156.     kIP_ADD_MEMBERSHIP            = 0x1013,                        /* add an IP group membership        */
  157.     kIP_DROP_MEMBERSHIP            = 0x1014,                        /* drop an IP group membership        */
  158.     kIP_BROADCAST_IFNAME        = 0x1015,                        /* Set interface for broadcasts     */
  159.     kIP_RCVIFADDR                = 0x1016                        /* Set interface for broadcasts     */
  160. };
  161.  
  162. /*
  163.  * The value of some of the following constants may conflict with 
  164.  * the values found in the BSD header netinet/in.h.
  165.  * Use instead the constant defined in the enum, for example use 
  166.  * kIP_OPTIONS instead of IP_OPTIONS.
  167.  */
  168. #ifndef IP_OPTIONS
  169. enum {
  170.     IP_OPTIONS                    = kIP_OPTIONS,
  171.     IP_TOS                        = kIP_TOS,
  172.     IP_TTL                        = kIP_TTL,
  173.     IP_REUSEADDR                = kIP_REUSEADDR,
  174.     IP_DONTROUTE                = kIP_DONTROUTE,
  175.     IP_BROADCAST                = kIP_BROADCAST,
  176.     IP_REUSEPORT                = kIP_REUSEPORT,
  177.     IP_HDRINCL                    = kIP_HDRINCL,
  178.     IP_RCVOPTS                    = kIP_RCVOPTS,
  179.     IP_RCVDSTADDR                = kIP_RCVDSTADDR,
  180.     IP_MULTICAST_IF                = kIP_MULTICAST_IF,                /* set/get IP multicast interface    */
  181.     IP_MULTICAST_TTL            = kIP_MULTICAST_TTL,            /* set/get IP multicast timetolive    */
  182.     IP_MULTICAST_LOOP            = kIP_MULTICAST_LOOP,            /* set/get IP multicast loopback    */
  183.     IP_ADD_MEMBERSHIP            = kIP_ADD_MEMBERSHIP,            /* add an IP group membership        */
  184.     IP_DROP_MEMBERSHIP            = kIP_DROP_MEMBERSHIP,            /* drop an IP group membership        */
  185.     IP_BROADCAST_IFNAME            = kIP_BROADCAST_IFNAME,            /* Set interface for broadcasts     */
  186.     IP_RCVIFADDR                = kIP_RCVIFADDR                    /* Set interface for broadcasts     */
  187. };
  188.  
  189. #endif
  190.  
  191. enum {
  192.     DVMRP_INIT                    = 100,                            /* DVMRP-specific setsockopt commands, from ip_mroute.h*/
  193.     DVMRP_DONE                    = 101,
  194.     DVMRP_ADD_VIF                = 102,
  195.     DVMRP_DEL_VIF                = 103,
  196.     DVMRP_ADD_LGRP                = 104,
  197.     DVMRP_DEL_LGRP                = 105,
  198.     DVMRP_ADD_MRT                = 106,
  199.     DVMRP_DEL_MRT                = 107
  200. };
  201.  
  202.  
  203. /* IP_TOS precdence levels*/
  204.  
  205. enum {
  206.     T_ROUTINE                    = 0,
  207.     T_PRIORITY                    = 1,
  208.     T_IMMEDIATE                    = 2,
  209.     T_FLASH                        = 3,
  210.     T_OVERRIDEFLASH                = 4,
  211.     T_CRITIC_ECP                = 5,
  212.     T_INETCONTROL                = 6,
  213.     T_NETCONTROL                = 7
  214. };
  215.  
  216. /*    IP_TOS type of service*/
  217.  
  218. enum {
  219.     T_NOTOS                        = 0x00,
  220.     T_LDELAY                    = (1 << 4),
  221.     T_HITHRPT                    = (1 << 3),
  222.     T_HIREL                        = (1 << 2)
  223. };
  224.  
  225. #define    SET_TOS(prec,tos)    (((0x7 & (prec)) << 5) | (0x1c & (tos)))
  226. /* IP Multicast option structures*/
  227.  
  228.  
  229. struct TIPAddMulticast {
  230.     InetHost                         multicastGroupAddress;
  231.     InetHost                         interfaceAddress;
  232. };
  233. typedef struct TIPAddMulticast            TIPAddMulticast;
  234. /* Protocol-specific events*/
  235. enum {
  236.     T_DNRSTRINGTOADDRCOMPLETE    = kPRIVATEEVENT + 1,
  237.     T_DNRADDRTONAMECOMPLETE        = kPRIVATEEVENT + 2,
  238.     T_DNRSYSINFOCOMPLETE        = kPRIVATEEVENT + 3,
  239.     T_DNRMAILEXCHANGECOMPLETE    = kPRIVATEEVENT + 4,
  240.     T_DNRQUERYCOMPLETE            = kPRIVATEEVENT + 5
  241. };
  242.  
  243. /* InetAddress*/
  244.  
  245.  
  246. struct InetAddress {
  247.     OTAddressType                     fAddressType;                /* always AF_INET*/
  248.     InetPort                         fPort;                        /* Port number */
  249.     InetHost                         fHost;                        /* Host address in net byte order*/
  250.     UInt8                             fUnused[8];                    /* Traditional unused bytes*/
  251. };
  252. typedef struct InetAddress                InetAddress;
  253. /* Domain Name Resolver (DNR) */
  254. enum {
  255.     kMaxHostAddrs                = 10,
  256.     kMaxSysStringLen            = 32,
  257.     kMaxHostNameLen                = 255
  258. };
  259.  
  260.  
  261. typedef char                             InetDomainName[256];
  262.  
  263. struct InetHostInfo {
  264.     InetDomainName                     name;
  265.     InetHost                         addrs[10];
  266. };
  267. typedef struct InetHostInfo                InetHostInfo;
  268.  
  269. struct InetSysInfo {
  270.     char                             cpuType[32];
  271.     char                             osType[32];
  272. };
  273. typedef struct InetSysInfo                InetSysInfo;
  274.  
  275. struct InetMailExchange {
  276.     UInt16                             preference;
  277.     InetDomainName                     exchange;
  278. };
  279. typedef struct InetMailExchange            InetMailExchange;
  280.  
  281. struct DNSQueryInfo {
  282.     UInt16                             qType;
  283.     UInt16                             qClass;
  284.     UInt32                             ttl;
  285.     InetDomainName                     name;
  286.     UInt16                             responseType;                /* answer, authority, or additional*/
  287.     UInt16                             resourceLen;                /* actual length of array which follows*/
  288.     char                             resourceData[4];            /* size varies*/
  289. };
  290. typedef struct DNSQueryInfo                DNSQueryInfo;
  291. /* DNSAddress*/
  292. /*
  293.    The DNSAddress format is optional and may be used in connects,
  294.    datagram sends, and resolve address calls.   The name takes the 
  295.    format "somewhere.com" or "somewhere.com:portnumber" where
  296.    the ":portnumber" is optional.   The length of this structure
  297.    is arbitrarily limited to the overall max length of a domain
  298.    name (255 chars), although a longer one can be use successfully
  299.    if you use this as a template for doing so.   However, the domain name 
  300.    is still limited to 255 characters.
  301. */
  302.  
  303.  
  304. struct DNSAddress {
  305.     OTAddressType                     fAddressType;                /* always AF_DNS*/
  306.     InetDomainName                     fName;
  307. };
  308. typedef struct DNSAddress                DNSAddress;
  309. /* InetInterfaceInfo*/
  310. enum {
  311.     kDefaultInetInterface        = -1
  312. };
  313.  
  314. enum {
  315.     kInetInterfaceInfoVersion    = 3
  316. };
  317.  
  318.  
  319. struct InetInterfaceInfo {
  320.     InetHost                         fAddress;
  321.     InetHost                         fNetmask;
  322.     InetHost                         fBroadcastAddr;
  323.     InetHost                         fDefaultGatewayAddr;
  324.     InetHost                         fDNSAddr;
  325.     UInt16                             fVersion;
  326.     UInt16                             fHWAddrLen;
  327.     UInt8 *                            fHWAddr;
  328.     UInt32                             fIfMTU;
  329.     UInt8 *                            fReservedPtrs[2];
  330.     InetDomainName                     fDomainName;
  331.     UInt32                             fIPSecondaryCount;
  332.     UInt8                             fReserved[252];
  333. };
  334. typedef struct InetInterfaceInfo        InetInterfaceInfo;
  335. /* InetDHCPOption*/
  336. enum {
  337.     kAllDHCPOptions                = -1,
  338.     kDHCPLongOption                = 126,
  339.     kDHCPLongOptionReq            = 127
  340. };
  341.  
  342.  
  343. struct InetDHCPOption {
  344.     UInt8                             fOptionTag;
  345.     UInt8                             fOptionLen;
  346.     UInt8                             fOptionValue;
  347. };
  348. typedef struct InetDHCPOption            InetDHCPOption;
  349. /* TCP/IP Utility Routines*/
  350.  
  351. EXTERN_API( void )
  352. OTInitInetAddress                (InetAddress *            addr,
  353.                                  InetPort                 port,
  354.                                  InetHost                 host);
  355.  
  356. EXTERN_API( OTByteCount )
  357. OTInitDNSAddress                (DNSAddress *            addr,
  358.                                  char *                    str);
  359.  
  360. EXTERN_API( OSStatus )
  361. OTInetStringToHost                (char *                    str,
  362.                                  InetHost *                host);
  363.  
  364. EXTERN_API( void )
  365. OTInetHostToString                (InetHost                 host,
  366.                                  char *                    str);
  367.  
  368. EXTERN_API( OSStatus )
  369. OTInetGetInterfaceInfo            (InetInterfaceInfo *    info,
  370.                                  SInt32                 val);
  371.  
  372. EXTERN_API( OSStatus )
  373. OTInetGetSecondaryAddresses        (InetHost *                addr,
  374.                                  UInt32 *                count,
  375.                                  SInt32                 val);
  376.  
  377. EXTERN_API( OSStatus )
  378. OTInetGetDHCPConfigInfo            (InetDHCPOption *        buf,
  379.                                  UInt32                 bufSize,
  380.                                  SInt32                 index,
  381.                                  SInt32                 opt);
  382.  
  383. /* InetServices & DNR Calls*/
  384.  
  385. #if !OTKERNEL
  386. /*
  387.    Under Carbon, OTOpenInternetServices routines take a client context pointer.  Applications may pass NULL
  388.    after calling InitOpenTransport(kInitOTForApplicationMask, ...).  Non-applications must always pass a
  389.    valid client context.
  390. */
  391. EXTERN_API( InetSvcRef )
  392. OTOpenInternetServicesInContext    (OTConfigurationRef     cfig,
  393.                                  OTOpenFlags             oflag,
  394.                                  OSStatus *                err,
  395.                                  OTClientContextPtr     clientContext);
  396.  
  397. EXTERN_API( OSStatus )
  398. OTAsyncOpenInternetServicesInContext (OTConfigurationRef  cfig,
  399.                                  OTOpenFlags             oflag,
  400.                                  OTNotifyUPP             upp,
  401.                                  void *                    contextPtr,
  402.                                  OTClientContextPtr     clientContext);
  403.  
  404. EXTERN_API( InetSvcRef )
  405. OTOpenInternetServices            (OTConfigurationRef     cfig,
  406.                                  OTOpenFlags             oflag,
  407.                                  OSStatus *                err);
  408.  
  409. EXTERN_API( OSStatus )
  410. OTAsyncOpenInternetServices        (OTConfigurationRef     cfig,
  411.                                  OTOpenFlags             oflag,
  412.                                  OTNotifyProcPtr         proc,
  413.                                  void *                    contextPtr);
  414.  
  415. #if TARGET_API_MAC_CARBON
  416. /* The following macro may be used by applications only.*/
  417. #define OTOpenInternetServices(cfig, oflags, err) OTOpenInternetServicesInContext(cfig, oflags, err, NULL)
  418. #define OTAsyncOpenInternetServices(cfig, oflags, proc, contextPtr)  OTAsyncOpenInternetServicesInContext(cfig, oflags, proc, contextPtr, NULL)
  419. #endif  /* TARGET_API_MAC_CARBON */
  420.  
  421. EXTERN_API( OSStatus )
  422. OTInetStringToAddress            (InetSvcRef             ref,
  423.                                  char *                    name,
  424.                                  InetHostInfo *            hinfo);
  425.  
  426. EXTERN_API( OSStatus )
  427. OTInetAddressToName                (InetSvcRef             ref,
  428.                                  InetHost                 addr,
  429.                                  InetDomainName         name);
  430.  
  431. EXTERN_API( OSStatus )
  432. OTInetSysInfo                    (InetSvcRef             ref,
  433.                                  char *                    name,
  434.                                  InetSysInfo *            sysinfo);
  435.  
  436. EXTERN_API( OSStatus )
  437. OTInetMailExchange                (InetSvcRef             ref,
  438.                                  char *                    name,
  439.                                  UInt16 *                num,
  440.                                  InetMailExchange *        mx);
  441.  
  442. EXTERN_API( OSStatus )
  443. OTInetQuery                        (InetSvcRef             ref,
  444.                                  char *                    name,
  445.                                  UInt16                 qClass,
  446.                                  UInt16                 qType,
  447.                                  char *                    buf,
  448.                                  OTByteCount             buflen,
  449.                                  void **                argv,
  450.                                  OTByteCount             argvlen,
  451.                                  OTFlags                 flags);
  452.  
  453. #ifdef __cplusplus
  454. }                    // Terminate C definitions
  455.  
  456. class TInternetServices : public TProvider
  457. {
  458.     public:
  459.             OSStatus     StringToAddress(char* name, InetHostInfo* hinfo)
  460.                         { return OTInetStringToAddress(this, name, hinfo); }
  461.                     
  462.             OSStatus     AddressToName(InetHost addr, InetDomainName name)
  463.                         { return OTInetAddressToName(this, addr, name); }
  464.                     
  465.             OSStatus     SysInfo(char* name, InetSysInfo* sysinfo )
  466.                         { return OTInetSysInfo(this, name, sysinfo); }
  467.                     
  468.             OSStatus     MailExchange(char* name, UInt16* num, InetMailExchange* mx)
  469.                         { return OTInetMailExchange(this, name, num, mx); }
  470.                         
  471.             OSStatus    Query(char* name, UInt16 qClass, UInt16 qType, 
  472.                               char* buf, OTByteCount buflen, 
  473.                               void** argv, OTByteCount argvlen,
  474.                               OTFlags flags)
  475.                         { return OTInetQuery(this, name, qClass, qType, buf, buflen, argv, argvlen, flags); }
  476. };
  477.  
  478. extern "C" {        /* resume C definitions */
  479. #endif
  480. #endif  /* !OTKERNEL */
  481.  
  482. /* ***** AppleTalk ******/
  483. /* Shared library prefixes*/
  484.  
  485.  
  486. #define kATalkVersion    "1.1"
  487. #define kATalkPrefix    "ot:atlk$"
  488. #define kATBinderID        "ot:atbd$"
  489.  
  490. /*******************************************************************************
  491. ** Module definitions
  492. ********************************************************************************/
  493. /* XTI Levels*/
  494.  
  495. enum {
  496.     ATK_DDP                        = FOUR_CHAR_CODE('DDP '),
  497.     ATK_AARP                    = FOUR_CHAR_CODE('AARP'),
  498.     ATK_ATP                        = FOUR_CHAR_CODE('ATP '),
  499.     ATK_ADSP                    = FOUR_CHAR_CODE('ADSP'),
  500.     ATK_ASP                        = FOUR_CHAR_CODE('ASP '),
  501.     ATK_PAP                        = FOUR_CHAR_CODE('PAP '),
  502.     ATK_NBP                        = FOUR_CHAR_CODE('NBP '),
  503.     ATK_ZIP                        = FOUR_CHAR_CODE('ZIP ')
  504. };
  505.  
  506. /* Module Names*/
  507.  
  508.  
  509. #define kDDPName        "ddp"
  510. #define    kATPName        "atp"
  511. #define kADSPName        "adsp"
  512. #define    kASPName        "asp"
  513. #define kPAPName        "pap"
  514. #define kNBPName        "nbp"
  515. #define kZIPName        "zip"
  516. #define kLTalkName        "ltlk"
  517. #define kLTalkAName        "ltlkA"
  518. #define kLTalkBName        "ltlkB"
  519.  
  520. /*
  521.    Protocol-specific Options
  522.    NOTE:
  523.    All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  524.    ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  525.                    OPT_INTERVAL (# Milliseconds to wait)
  526. */
  527.  
  528. enum {
  529.     DDP_OPT_CHECKSUM            = 0x0600,
  530.     DDP_OPT_SRCADDR                = 0x2101,                        /* DDP UnitDataReq Only - set src address, Value is DDPAddress */
  531.     ATP_OPT_REPLYCNT            = 0x2110,                        /* AppleTalk - ATP Resp Pkt Ct Type, Value is (unsigned long)  pkt count */
  532.     ATP_OPT_DATALEN                = 0x2111,                        /* AppleTalk - ATP Pkt Data Len Type, Value is (unsigned long) length */
  533.     ATP_OPT_RELTIMER            = 0x2112,                        /* AppleTalk - ATP Release Timer Type, Value is (unsigned long) timer, (See Inside AppleTalk, second edition */
  534.     ATP_OPT_TRANID                = 0x2113,                        /* Value is (unsigned long) Boolean, Used to request Transaction ID, Returned with Transaction ID on requests */
  535.     PAP_OPT_OPENRETRY            = 0x2120                        /* AppleTalk - PAP OpenConn Retry count, Value is (unsigned long) T_YES/T_NO */
  536. };
  537.  
  538. /* Protocol-Specific Events*/
  539.  
  540. /*
  541.    If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  542.    you will receive the T_ATALKxxx events on your endpoint.
  543.    NOTE: The endpoint does not need to be bound.
  544. */
  545.  
  546. enum {
  547.     kAppleTalkEvent                = kPROTOCOLEVENT | 0x00010000,
  548.     T_GETMYZONECOMPLETE            = kAppleTalkEvent + 1,
  549.     T_GETLOCALZONESCOMPLETE        = kAppleTalkEvent + 2,
  550.     T_GETZONELISTCOMPLETE        = kAppleTalkEvent + 3,
  551.     T_GETATALKINFOCOMPLETE        = kAppleTalkEvent + 4,
  552.     T_ATALKROUTERDOWNEVENT        = kAppleTalkEvent + 51,            /* No routers have been seen for a while.  If the cookie is NULL, all routers are gone.  Otherwise, there is still an ARA router hanging around being used, and only the local cable has been  timed out.*/
  553.     T_ATALKROUTERUPEVENT        = kAppleTalkEvent + 52,            /* We didn't have a router, but now one has come up. Cookie is NULL for a normal router coming up, non-NULL for an ARA router coming on-line*/
  554.     T_ATALKZONENAMECHANGEDEVENT    = kAppleTalkEvent + 53,            /* A Zone name change was issued from the router, so our AppleTalk Zone has changed.*/
  555.     T_ATALKCONNECTIVITYCHANGEDEVENT = kAppleTalkEvent + 54,        /* An ARA connection was established (cookie != NULL), or was disconnected (cookie == NULL)*/
  556.     T_ATALKINTERNETAVAILABLEEVENT = kAppleTalkEvent + 55,        /* A router has appeared, and our address is in the startup range.  Cookie is hi/lo of new cable range.*/
  557.     T_ATALKCABLERANGECHANGEDEVENT = kAppleTalkEvent + 56        /* A router has appeared, and it's incompatible with our current address.  Cookie is hi/lo of new cable range.*/
  558. };
  559.  
  560. enum {
  561.     kAllATalkRoutersDown        = 0,                            /* This indicates that all routers are offline*/
  562.     kLocalATalkRoutersDown        = -1L,                            /* This indicates that all local routers went offline, but an ARA router is still active*/
  563.     kARARouterDisconnected        = -2L                            /* This indicates that ARA was disconnected, do it's router went offline, and we have no local routers to fall back onto.*/
  564. };
  565.  
  566. enum {
  567.     kARARouterOnline            = -1L,                            /* We had no local routers, but an ARA router is now online.*/
  568.     kATalkRouterOnline            = 0,                            /* We had no routers, but a local router is now online*/
  569.     kLocalATalkRouterOnline        = -2L                            /* We have an ARA router, but now we've seen a local router as well*/
  570. };
  571.  
  572. #define IsAppleTalkEvent(x)            ((x) & 0xffff0000) == kAppleTalkEvent)
  573. /* Protocol-specific IOCTLs*/
  574.  
  575. enum {
  576.     ATALK_IOC_FULLSELFSEND        = ((MIOC_ATALK << 8) | 47),        /* Turn on/off full self-send (it's automatic for non-backward-compatible links)*/
  577.     ADSP_IOC_FORWARDRESET        = ((MIOC_ATALK << 8) | 60)        /* ADSP Forward Reset*/
  578. };
  579.  
  580. /* Protocol-specific constants*/
  581.  
  582. /* ECHO*/
  583.  
  584. enum {
  585.     kECHO_TSDU                    = 585                            /* Max. # of data bytes.*/
  586. };
  587.  
  588. /* NBP*/
  589.  
  590. enum {
  591.     kNBPMaxNameLength            = 32,
  592.     kNBPMaxTypeLength            = 32,
  593.     kNBPMaxZoneLength            = 32,
  594.     kNBPSlushLength                = 9,                            /* Extra space for @, : and a few escape chars*/
  595.     kNBPMaxEntityLength            = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + 3),
  596.     kNBPEntityBufferSize        = (kNBPMaxNameLength + kNBPMaxTypeLength + kNBPMaxZoneLength + kNBPSlushLength),
  597.     kNBPWildCard                = 0x3D,                            /* NBP name and type match anything '='*/
  598.     kNBPImbeddedWildCard        = 0xC5,                            /* NBP name and type match some '*'*/
  599.     kNBPDefaultZone                = 0x2A                            /* NBP default zone '*'*/
  600. };
  601.  
  602. /* ZIP*/
  603.  
  604. enum {
  605.     kZIPMaxZoneLength            = kNBPMaxZoneLength
  606. };
  607.  
  608. enum {
  609.     kDDPAddressLength            = 8,                            /* value to use in netbuf.len field, Maximum length of AppleTalk address*/
  610.     kNBPAddressLength            = kNBPEntityBufferSize,
  611.     kAppleTalkAddressLength        = kDDPAddressLength + kNBPEntityBufferSize
  612. };
  613.  
  614.  
  615. #define OTCopyDDPAddress(addr, dest)                \
  616.     {                                                \
  617.         ((UInt32*)(dest))[0] = ((UInt32*)(addr))[0];    \
  618.         ((UInt32*)(dest))[1] = ((UInt32*)(addr))[1];    \
  619.     }
  620.  
  621. /*******************************************************************************
  622. ** CLASS TAppleTalkServices
  623. ********************************************************************************/
  624. #if !OTKERNEL
  625. /*
  626.    Define the ATSvcRef type.  This type needs special
  627.    processing because in C++ it's a subclass of TProvider.
  628.    See the definition of TEndpointRef in "OpenTransport.h"
  629.    for the logic behind this definition.
  630. */
  631. #ifdef __cplusplus
  632.     typedef class TAppleTalkServices*    ATSvcRef;
  633. #else
  634.     typedef void*    ATSvcRef;
  635. #endif
  636. #define kDefaultAppleTalkServicesPath        ((OTConfigurationRef)-3L)
  637. /*
  638.    Under Carbon, OpenAppleTalkServices routines take a client context pointer.  Applications may pass NULL
  639.    after calling InitOpenTransport(kInitOTForApplicationMask, ...).  Non-applications must always pass a
  640.    valid client context.
  641. */
  642. EXTERN_API( OSStatus )
  643. OTAsyncOpenAppleTalkServicesInContext (OTConfigurationRef  cfig,
  644.                                  OTOpenFlags             flags,
  645.                                  OTNotifyUPP             proc,
  646.                                  void *                    contextPtr,
  647.                                  OTClientContextPtr     clientContext);
  648.  
  649. EXTERN_API( ATSvcRef )
  650. OTOpenAppleTalkServicesInContext (OTConfigurationRef     cfig,
  651.                                  OTOpenFlags             flags,
  652.                                  OSStatus *                err,
  653.                                  OTClientContextPtr     clientContext);
  654.  
  655. EXTERN_API( OSStatus )
  656. OTAsyncOpenAppleTalkServices    (OTConfigurationRef     cfig,
  657.                                  OTOpenFlags             flags,
  658.                                  OTNotifyProcPtr         proc,
  659.                                  void *                    contextPtr);
  660.  
  661. EXTERN_API( ATSvcRef )
  662. OTOpenAppleTalkServices            (OTConfigurationRef     cfig,
  663.                                  OTOpenFlags             flags,
  664.                                  OSStatus *                err);
  665.  
  666. #if TARGET_API_MAC_CARBON
  667. /* The following macro may be used by applications only.*/
  668. #define OTOpenAppleTalkServices(cfig, oflags, err) OTOpenAppleTalkServicesInContext(cfig, oflags, err, NULL)
  669. #define OTAsyncOpenAppleTalkServices(cfig, oflags, proc, contextPtr) OTAsyncOpenAppleTalkServicesInContext(cfig, oflags, proc, contextPtr, NULL)
  670. #endif  /* TARGET_API_MAC_CARBON */
  671.  
  672. /* Get the zone associated with the ATSvcRef*/
  673. EXTERN_API( OSStatus )
  674. OTATalkGetMyZone                (ATSvcRef                 ref,
  675.                                  TNetbuf *                zone);
  676.  
  677. /*
  678.    Get the list of available zones associated with the local cable
  679.    of the ATSvcRef
  680. */
  681. EXTERN_API( OSStatus )
  682. OTATalkGetLocalZones            (ATSvcRef                 ref,
  683.                                  TNetbuf *                zones);
  684.  
  685. /* Get the list of all zones on the internet specified by the ATSvcRef*/
  686. EXTERN_API( OSStatus )
  687. OTATalkGetZoneList                (ATSvcRef                 ref,
  688.                                  TNetbuf *                zones);
  689.  
  690. /* Stores an AppleTalkInfo structure into the TNetbuf (see later in this file)*/
  691. EXTERN_API( OSStatus )
  692. OTATalkGetInfo                    (ATSvcRef                 ref,
  693.                                  TNetbuf *                info);
  694.  
  695. #ifdef __cplusplus
  696. }                    // Terminate C definitions
  697.  
  698. class TAppleTalkServices : public TProvider
  699. {
  700.     public:
  701.             OSStatus    GetMyZone(TNetbuf* zone)         { return OTATalkGetMyZone(this, zone); }
  702.             OSStatus    GetLocalZones(TNetbuf* zones)    { return OTATalkGetLocalZones(this, zones); }
  703.             OSStatus    GetZoneList(TNetbuf* zones)        { return OTATalkGetZoneList(this, zones); }
  704.             OSStatus    GetInfo(TNetbuf* info)            { return OTATalkGetInfo(this, info); }
  705. };
  706.  
  707. extern "C" {        /* resume C definitions */
  708. #endif    /* _cplus */
  709. #endif  /* !OTKERNEL */
  710.  
  711. /* AppleTalk Addressing*/
  712. /*
  713.    The NBPEntity structure is used to manipulate NBP names without regard
  714.    to issues of what kind of "special" characters are in the name.
  715.    
  716.    When stored as an address in an NBPAddress or DDPNBPAddress, they are 
  717.    stored as a character string, which is currently just ASCII, but in the
  718.    future may be UniChar, or some other internationalizable scripting set.
  719.    The string following an NBPAddress or DDPNBPAddress is intended to be
  720.    suitable for showing to users, whereas NBPEntity is not.
  721.    WARNING: NBPAddress and DDPNBPAddress structures do not "know" the length
  722.    of the address.  That must have been obtained as part of a Lookup or
  723.    ResolveAddress call.
  724. */
  725.  
  726. enum {
  727.     AF_ATALK_FAMILY                = 0x0100,
  728.     AF_ATALK_DDP                = 0x0100,
  729.     AF_ATALK_DDPNBP                = AF_ATALK_FAMILY + 1,
  730.     AF_ATALK_NBP                = AF_ATALK_FAMILY + 2,
  731.     AF_ATALK_MNODE                = AF_ATALK_FAMILY + 3
  732. };
  733.  
  734.  
  735. struct NBPEntity {
  736.     UInt8                             fEntity[99];
  737. };
  738. typedef struct NBPEntity                NBPEntity;
  739.  
  740. struct DDPAddress {
  741.     OTAddressType                     fAddressType;                /* One of the enums above*/
  742.     UInt16                             fNetwork;
  743.     UInt8                             fNodeID;
  744.     UInt8                             fSocket;
  745.     UInt8                             fDDPType;
  746.     UInt8                             fPad;
  747.  
  748. #ifdef __cplusplus
  749.     // C++ inline methods on this structure.
  750.  
  751.     void            Init(const DDPAddress&);
  752.     void            Init(UInt16 net, UInt8 node, UInt8 socket);
  753.     void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  754.  
  755.     void            SetSocket(UInt8);
  756.     void            SetType(UInt8);
  757.     void            SetNode(UInt8);
  758.     void            SetNetwork(UInt16);
  759.  
  760.     OTByteCount        GetAddressLength() const;
  761.     OTAddressType    GetAddressType() const;
  762.     UInt8            GetSocket() const;
  763.     UInt8            GetType() const;
  764.     UInt8            GetNode() const;
  765.     UInt16            GetNetwork() const;
  766.  
  767.     Boolean            operator==(const DDPAddress&) const;
  768.     Boolean            operator!=(const DDPAddress&) const;
  769.     void            operator=(const DDPAddress&);
  770. #endif
  771.  
  772.  
  773. };
  774. typedef struct DDPAddress                DDPAddress;
  775.  
  776. struct NBPAddress {
  777.     OTAddressType                     fAddressType;                /* One of the enums above*/
  778.     UInt8                             fNBPNameBuffer[105];
  779.  
  780. #ifdef __cplusplus
  781.     // C++ inline methods on this structure.
  782.  
  783.     OTByteCount        Init();
  784.     OTByteCount        Init(const NBPEntity&);
  785.     OTByteCount        Init(const char*);
  786.     OTByteCount        Init(const char*, OTByteCount len);
  787.     Boolean            ExtractEntity(NBPEntity&, OTByteCount len);
  788.  
  789.     OTAddressType    GetAddressType() const;
  790. #endif
  791.  
  792.  
  793. };
  794. typedef struct NBPAddress                NBPAddress;
  795.  
  796. struct DDPNBPAddress {
  797.     OTAddressType                     fAddressType;                /* One of the enums above*/
  798.     UInt16                             fNetwork;
  799.     UInt8                             fNodeID;
  800.     UInt8                             fSocket;
  801.     UInt8                             fDDPType;
  802.     UInt8                             fPad;
  803.     UInt8                             fNBPNameBuffer[105];
  804.  
  805. #ifdef __cplusplus
  806.     // C++ inline methods on this structure.
  807.  
  808.     void            Init(const DDPAddress&);
  809.     void            Init(UInt16 net, UInt8 node, UInt8 socket);
  810.     void            Init(UInt16 net, UInt8 node, UInt8 socket, UInt8 type);
  811.  
  812.     void            SetSocket(UInt8);
  813.     void            SetType(UInt8);
  814.     void            SetNode(UInt8);
  815.     void            SetNetwork(UInt16);
  816.     
  817.     OTAddressType    GetAddressType() const;
  818.     UInt8            GetSocket() const;
  819.     UInt8            GetType() const;
  820.     UInt8            GetNode() const;
  821.     UInt16            GetNetwork() const;
  822.     
  823.     Boolean            ExtractEntity(NBPEntity&, OTByteCount len);
  824.     OTByteCount        SetNBPEntity(const NBPEntity&);
  825.     OTByteCount        SetNBPEntity(const char*);
  826.     OTByteCount        SetNBPEntity(const char*, OTByteCount len);
  827.     
  828.     Boolean            operator==(const DDPAddress&) const;
  829. #endif
  830.  
  831.  
  832. };
  833. typedef struct DDPNBPAddress            DDPNBPAddress;
  834. /* These are some utility routines for dealing with NBP and DDP addresses. */
  835.  
  836. /* Functions to initialize the various AppleTalk Address types*/
  837. EXTERN_API( void )
  838. OTInitDDPAddress                (DDPAddress *            addr,
  839.                                  UInt16                 net,
  840.                                  UInt8                     node,
  841.                                  UInt8                     socket,
  842.                                  UInt8                     ddpType);
  843.  
  844. EXTERN_API( OTByteCount )
  845. OTInitNBPAddress                (NBPAddress *            addr,
  846.                                  const char *            name);
  847.  
  848. EXTERN_API( OTByteCount )
  849. OTInitDDPNBPAddress                (DDPNBPAddress *        addr,
  850.                                  const char *            name,
  851.                                  UInt16                 net,
  852.                                  UInt8                     node,
  853.                                  UInt8                     socket,
  854.                                  UInt8                     ddpType);
  855.  
  856. /* Compare 2 DDP addresses for equality*/
  857. EXTERN_API( Boolean )
  858. OTCompareDDPAddresses            (const DDPAddress *        addr1,
  859.                                  const DDPAddress *        addr2);
  860.  
  861. /* Init an NBPEntity to a NULL name*/
  862. EXTERN_API( void )
  863. OTInitNBPEntity                    (NBPEntity *            entity);
  864.  
  865. /* Get the length an NBPEntity would have when stored as an address*/
  866. EXTERN_API( OTByteCount )
  867. OTGetNBPEntityLengthAsAddress    (const NBPEntity *        entity);
  868.  
  869. /* Store an NBPEntity into an address buffer*/
  870. EXTERN_API( OTByteCount )
  871. OTSetAddressFromNBPEntity        (UInt8 *                nameBuf,
  872.                                  const NBPEntity *        entity);
  873.  
  874. /* Create an address buffer from a string (use -1 for len to use strlen)*/
  875. EXTERN_API( OTByteCount )
  876. OTSetAddressFromNBPString        (UInt8 *                addrBuf,
  877.                                  const char *            name,
  878.                                  SInt32                 len);
  879.  
  880. /*
  881.    Create an NBPEntity from an address buffer. False is returned if
  882.      the address was truncated.
  883. */
  884. EXTERN_API( Boolean )
  885. OTSetNBPEntityFromAddress        (NBPEntity *            entity,
  886.                                  const UInt8 *            addrBuf,
  887.                                  OTByteCount             len);
  888.  
  889. /* Routines to set a piece of an NBP entity from a character string*/
  890. EXTERN_API( Boolean )
  891. OTSetNBPName                    (NBPEntity *            entity,
  892.                                  const char *            name);
  893.  
  894. EXTERN_API( Boolean )
  895. OTSetNBPType                    (NBPEntity *            entity,
  896.                                  const char *            typeVal);
  897.  
  898. EXTERN_API( Boolean )
  899. OTSetNBPZone                    (NBPEntity *            entity,
  900.                                  const char *            zone);
  901.  
  902. /* Routines to extract pieces of an NBP entity*/
  903. EXTERN_API( void )
  904. OTExtractNBPName                (const NBPEntity *        entity,
  905.                                  char *                    name);
  906.  
  907. EXTERN_API( void )
  908. OTExtractNBPType                (const NBPEntity *        entity,
  909.                                  char *                    typeVal);
  910.  
  911. EXTERN_API( void )
  912. OTExtractNBPZone                (const NBPEntity *        entity,
  913.                                  char *                    zone);
  914.  
  915. #ifdef __cplusplus
  916.  
  917. // Inline methods for DDPAddress
  918.  
  919. inline void DDPAddress::operator=(const DDPAddress& addr)
  920. {
  921.     *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  922.     *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  923. }
  924.  
  925. inline Boolean DDPAddress::operator==(const DDPAddress& addr) const
  926. {
  927.     return OTCompareDDPAddresses(&addr, this);
  928. }
  929.  
  930. inline Boolean DDPAddress::operator!=(const DDPAddress& addr) const
  931. {
  932.     return !OTCompareDDPAddresses(&addr, this);
  933. }
  934.  
  935. inline void DDPAddress::SetSocket(UInt8 socket)
  936. {
  937.     fSocket = socket;
  938. }
  939.  
  940. inline void DDPAddress::SetNode(UInt8 node)
  941. {
  942.     fNodeID = node;
  943. }
  944.  
  945. inline void DDPAddress::SetType(UInt8 type)
  946. {
  947.     fDDPType = type;
  948. }
  949.  
  950. inline void DDPAddress::SetNetwork(UInt16 net)
  951. {
  952.     fNetwork = net;
  953. }
  954.  
  955. inline OTByteCount DDPAddress::GetAddressLength() const
  956. {
  957.     return kDDPAddressLength;
  958. }
  959.  
  960. inline OTAddressType DDPAddress::GetAddressType() const
  961. {
  962.     return fAddressType;
  963. }
  964.  
  965. inline UInt8 DDPAddress::GetSocket() const
  966. {
  967.     return fSocket;
  968. }
  969.  
  970. inline UInt8 DDPAddress::GetNode() const
  971. {
  972.     return fNodeID;
  973. }
  974.  
  975. inline UInt8 DDPAddress::GetType() const
  976. {
  977.     return fDDPType;
  978. }
  979.  
  980. inline UInt16 DDPAddress::GetNetwork() const
  981. {
  982.     return fNetwork;
  983. }
  984.  
  985. inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  986.                               UInt8 socket)
  987. {
  988.     fAddressType = AF_ATALK_DDP;
  989.     SetNetwork(net);
  990.     SetNode(node);
  991.     SetSocket(socket);
  992.     SetType(0);
  993. }
  994.  
  995. inline void  DDPAddress::Init(UInt16 net, UInt8 node,
  996.                               UInt8 socket, UInt8 type)
  997. {
  998.     fAddressType = AF_ATALK_DDP;
  999.     SetNetwork(net);
  1000.     SetNode(node);
  1001.     SetSocket(socket);
  1002.     SetType(type);
  1003. }
  1004.  
  1005. inline void DDPAddress::Init(const DDPAddress& addr)
  1006. {
  1007.     *(UInt32*)&fAddressType = *(UInt32*)&addr.fAddressType;
  1008.     *(UInt32*)&fNodeID = *(UInt32*)&addr.fNodeID;
  1009. }
  1010.  
  1011. // Inline methods for NBPAddress
  1012.  
  1013. inline OTByteCount NBPAddress::Init()
  1014. {
  1015.     fAddressType = AF_ATALK_NBP;
  1016.     return sizeof(OTAddressType);
  1017. }
  1018.  
  1019. inline OTByteCount NBPAddress::Init(const NBPEntity& addr)
  1020. {
  1021.     fAddressType = AF_ATALK_NBP;
  1022.     return sizeof(OTAddressType) + OTSetAddressFromNBPEntity(fNBPNameBuffer, &addr);
  1023. }
  1024.  
  1025. inline OTByteCount NBPAddress::Init(const char* name)
  1026. {
  1027.     fAddressType = AF_ATALK_NBP;
  1028.     return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, -1);
  1029. }
  1030.  
  1031. inline OTByteCount NBPAddress::Init(const char* name, OTByteCount len)
  1032. {
  1033.     fAddressType = AF_ATALK_NBP;
  1034.     return sizeof(OTAddressType) + OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len);
  1035. }
  1036.  
  1037. inline Boolean NBPAddress::ExtractEntity(NBPEntity& entity, OTByteCount len)
  1038. {
  1039.     return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  1040. }
  1041.     
  1042. inline OTAddressType NBPAddress::GetAddressType() const
  1043. {
  1044.     return fAddressType;
  1045. }
  1046.     
  1047. // Inline methods for DDPNBPAddress
  1048.  
  1049. inline Boolean DDPNBPAddress::operator==(const DDPAddress& addr) const
  1050. {
  1051.     return OTCompareDDPAddresses((const DDPAddress*)this, &addr);
  1052. }
  1053.  
  1054. inline void DDPNBPAddress::SetSocket(UInt8 socket)
  1055. {
  1056.     fSocket = socket;
  1057. }
  1058.  
  1059. inline void DDPNBPAddress::SetNode(UInt8 node)
  1060. {
  1061.     fNodeID = node;
  1062. }
  1063.  
  1064. inline void DDPNBPAddress::SetType(UInt8 type)
  1065. {
  1066.     fDDPType = type;
  1067. }
  1068.  
  1069. inline void DDPNBPAddress::SetNetwork(UInt16 net)
  1070. {
  1071.     fNetwork = net;
  1072. }
  1073.  
  1074. inline OTAddressType DDPNBPAddress::GetAddressType() const
  1075. {
  1076.     return fAddressType;
  1077. }
  1078.  
  1079. inline UInt8 DDPNBPAddress::GetSocket() const
  1080. {
  1081.     return fSocket;
  1082. }
  1083.  
  1084. inline UInt8 DDPNBPAddress::GetNode() const
  1085. {
  1086.     return fNodeID;
  1087. }
  1088.  
  1089. inline UInt8 DDPNBPAddress::GetType() const
  1090. {
  1091.     return fDDPType;
  1092. }
  1093.  
  1094. inline UInt16 DDPNBPAddress::GetNetwork() const
  1095. {
  1096.     return fNetwork;
  1097. }
  1098.  
  1099. inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  1100.                                 UInt8 socket)
  1101. {
  1102.     fAddressType = AF_ATALK_DDPNBP;
  1103.     SetNetwork(net);
  1104.     SetNode(node);
  1105.     SetSocket(socket);
  1106.     SetType(0);
  1107. }
  1108.  
  1109. inline void DDPNBPAddress::Init(UInt16 net, UInt8 node,
  1110.                                 UInt8 socket, UInt8 type)
  1111. {
  1112.     fAddressType = AF_ATALK_DDPNBP;
  1113.     SetNetwork(net);
  1114.     SetNode(node);
  1115.     SetSocket(socket);
  1116.     SetType(type);
  1117. }
  1118.  
  1119. inline void DDPNBPAddress::Init(const DDPAddress& addr)
  1120. {
  1121.     fAddressType = AF_ATALK_DDPNBP;
  1122.     SetNetwork(addr.GetNetwork());
  1123.     SetNode(addr.GetNode());
  1124.     SetSocket(addr.GetSocket());
  1125.     SetType(addr.GetType());
  1126.     fNBPNameBuffer[0] = 0;
  1127. }
  1128.  
  1129. inline OTByteCount DDPNBPAddress::SetNBPEntity(const NBPEntity& entity)
  1130. {
  1131.     return OTSetAddressFromNBPEntity(fNBPNameBuffer, &entity) + kDDPAddressLength;
  1132. }
  1133.  
  1134. inline OTByteCount DDPNBPAddress::SetNBPEntity(const char* name)
  1135. {
  1136.     return OTSetAddressFromNBPString(fNBPNameBuffer, name, -1) + kDDPAddressLength;
  1137. }
  1138.  
  1139. inline OTByteCount DDPNBPAddress::SetNBPEntity(const char* name, OTByteCount len)
  1140. {
  1141.     return OTSetAddressFromNBPString(fNBPNameBuffer, name, (SInt32)len) + kDDPAddressLength;
  1142. }
  1143.  
  1144. inline Boolean DDPNBPAddress::ExtractEntity(NBPEntity& entity, OTByteCount len)
  1145. {
  1146.     return OTSetNBPEntityFromAddress(&entity, fNBPNameBuffer, len);
  1147. }
  1148.  
  1149. #endif    /* __cplusplus */
  1150. /* AppleTalkInfo as used by the OTGetATalkInfo function*/
  1151.  
  1152.  
  1153. struct AppleTalkInfo {
  1154.     DDPAddress                         fOurAddress;                /* Our DDP address (network # & node)*/
  1155.     DDPAddress                         fRouterAddress;                /* The address of a router on our cable*/
  1156.     UInt16                             fCableRange[2];                /* The current cable range*/
  1157.     UInt16                             fFlags;                        /* See below*/
  1158. };
  1159. typedef struct AppleTalkInfo            AppleTalkInfo;
  1160. /* For the fFlags field in AppleTalkInfo*/
  1161. enum {
  1162.     kATalkInfoIsExtended        = 0x0001,                        /* This is an extended (phase 2) network*/
  1163.     kATalkInfoHasRouter            = 0x0002,                        /* This cable has a router*/
  1164.     kATalkInfoOneZone            = 0x0004                        /* This cable has only one zone*/
  1165. };
  1166.  
  1167. /* ***** Ethernet ******/
  1168.  
  1169. /* Interface option flags*/
  1170.  
  1171. /* Ethernet framing options*/
  1172.  
  1173. enum {
  1174.     kOTFramingEthernet            = 0x01,
  1175.     kOTFramingEthernetIPX        = 0x02,
  1176.     kOTFraming8023                = 0x04,
  1177.     kOTFraming8022                = 0x08
  1178. };
  1179.  
  1180. /*
  1181.    These are obsolete and will be going away in OT 1.5.
  1182.    Hmmm, OT 1.5 got cancelled.  The status of these options
  1183.    is uncertain.
  1184. */
  1185.  
  1186. /* RawMode options*/
  1187.  
  1188. enum {
  1189.     kOTRawRcvOn                    = 0,
  1190.     kOTRawRcvOff                = 1,
  1191.     kOTRawRcvOnWithTimeStamp    = 2
  1192. };
  1193.  
  1194. enum {
  1195.     DL_PROMISC_OFF                = 0                                /* OPT_SETPROMISCUOUS value*/
  1196. };
  1197.  
  1198. /* Module definitions*/
  1199.  
  1200. /* Module IDs*/
  1201.  
  1202. enum {
  1203.     kT8022ModuleID                = 7100,
  1204.     kEnetModuleID                = 7101,
  1205.     kTokenRingModuleID            = 7102,
  1206.     kFDDIModuleID                = 7103
  1207. };
  1208.  
  1209. /* Module Names*/
  1210.  
  1211.  
  1212. #define kEnet8022Name        "enet8022x"
  1213. #define kEnetName            "enet"
  1214. #define kFastEnetName        "fenet"
  1215. #define kTokenRingName        "tokn"
  1216. #define kFDDIName            "fddi"
  1217. #define kIRTalkName            "irtlk"
  1218. #define kSMDSName            "smds"
  1219. #define kATMName            "atm"
  1220. #define kT8022Name            "tpi8022x"
  1221. #define kATMSNAPName        "atmsnap"
  1222. #define kFireWireName        "firewire"
  1223. #define kFibreChannelName    "fibre"
  1224.  
  1225. /* Address Family*/
  1226.  
  1227. enum {
  1228.     AF_8022                        = 8200                            /* Our 802.2 generic address family*/
  1229. };
  1230.  
  1231. /* XTI Levels*/
  1232.  
  1233. enum {
  1234.     LNK_ENET                    = FOUR_CHAR_CODE('ENET'),
  1235.     LNK_TOKN                    = FOUR_CHAR_CODE('TOKN'),
  1236.     LNK_FDDI                    = FOUR_CHAR_CODE('FDDI'),
  1237.     LNK_TPI                        = FOUR_CHAR_CODE('LTPI')
  1238. };
  1239.  
  1240. /* Options*/
  1241.  
  1242. enum {
  1243.     OPT_ADDMCAST                = 0x1000,
  1244.     OPT_DELMCAST                = 0x1001,
  1245.     OPT_RCVPACKETTYPE            = 0x1002,
  1246.     OPT_RCVDESTADDR                = 0x1003,
  1247.     OPT_SETRAWMODE                = 0x1004,
  1248.     OPT_SETPROMISCUOUS            = 0x1005
  1249. };
  1250.  
  1251.  
  1252. typedef UInt32 OTPacketType;
  1253. enum {
  1254.     kETypeStandard                = 0,
  1255.     kETypeMulticast                = 1,
  1256.     kETypeBroadcast                = 2,
  1257.     kETRawPacketBit                = 0x80000000,
  1258.     kETTimeStampBit                = 0x40000000
  1259. };
  1260.  
  1261. /* Link related constants*/
  1262.  
  1263. enum {
  1264.     kMulticastLength            = 6,                            /* length of an ENET hardware addressaddress*/
  1265.     k48BitAddrLength            = 6,
  1266.     k8022DLSAPLength            = 2,                            /* The protocol type is our DLSAP*/
  1267.     k8022SNAPLength                = 5,
  1268.     kEnetAddressLength            = k48BitAddrLength + k8022DLSAPLength, /* length of an address field used by the ENET enpoint*/
  1269.                                                                 /*    = k48BitAddrLength + sizeof(protocol type)*/
  1270.     kSNAPSAP                    = 0x00AA,                        /* Special DLSAPS for ENET*/
  1271.     kIPXSAP                        = 0x00FF,
  1272.     kMax8022SAP                    = 0x00FE,
  1273.     k8022GlobalSAP                = 0x00FF,
  1274.     kMinDIXSAP                    = 1501,
  1275.     kMaxDIXSAP                    = 0xFFFF
  1276. };
  1277.  
  1278. /* Generic Address Structure*/
  1279.  
  1280.  
  1281. struct T8022Address {
  1282.     OTAddressType                     fAddrFamily;
  1283.     UInt8                             fHWAddr[6];
  1284.     UInt16                             fSAP;
  1285.     UInt8                             fSNAP[5];
  1286. };
  1287. typedef struct T8022Address                T8022Address;
  1288. enum {
  1289.     k8022BasicAddressLength        = sizeof(OTAddressType) + k48BitAddrLength + sizeof(UInt16),
  1290.     k8022SNAPAddressLength        = sizeof(OTAddressType) + k48BitAddrLength + sizeof(UInt16) + k8022SNAPLength
  1291. };
  1292.  
  1293. /* Some helpful stuff for dealing with 48 bit addresses*/
  1294.  
  1295.  
  1296. #define OTCompare48BitAddresses(p1, p2)                                                        \
  1297.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&        \
  1298.      *(const UInt16*)(((const UInt8*)(p1))+4) == *(const UInt16*)(((const UInt8*)(p2))+4) )
  1299.  
  1300. #define OTCopy48BitAddress(p1, p2)                                                \
  1301.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),            \
  1302.      *(UInt16*)(((UInt8*)(p2))+4) = *(const UInt16*)(((const UInt8*)(p1))+4) )
  1303.  
  1304. #define OTClear48BitAddress(p1)                                                    \
  1305.     (*(UInt32*)((UInt8*)(p1)) = 0,                                                \
  1306.      *(UInt16*)(((UInt8*)(p1))+4) = 0 )
  1307.  
  1308. #define OTCompare8022SNAP(p1, p2)                                                        \
  1309.     (*(const UInt32*)((const UInt8*)(p1)) == *(const UInt32*)((const UInt8*)(p2)) &&    \
  1310.      *(((const UInt8*)(p1))+4) == *(((const UInt8*)(p2))+4) )
  1311.  
  1312. #define OTCopy8022SNAP(p1, p2)                                                \
  1313.     (*(UInt32*)((UInt8*)(p2)) = *(const UInt32*)((const UInt8*)(p1)),        \
  1314.      *(((UInt8*)(p2))+4) = *(((const UInt8*)(p1))+4) )
  1315.  
  1316. #define OTIs48BitBroadcastAddress(p1)                    \
  1317.     (*(UInt32*)((UInt8*)(p1)) == 0xffffffff &&            \
  1318.      *(UInt16*)(((UInt8*)(p1))+4) == 0xffff )
  1319.  
  1320. #define OTSet48BitBroadcastAddress(p1)                    \
  1321.     (*(UInt32*)((UInt8*)(p1)) = 0xffffffff,                \
  1322.      *(UInt16*)(((UInt8*)(p1))+4) = 0xffff )
  1323.  
  1324. #define OTIs48BitZeroAddress(p1)                \
  1325.     (*(UInt32*)((UInt8*)(p1)) == 0 &&             \
  1326.      *(UInt16*)(((UInt8*)(p1))+4) == 0 )
  1327.  
  1328. /* Link related constants*/
  1329.  
  1330. enum {
  1331.     kEnetPacketHeaderLength        = (2 * k48BitAddrLength) + k8022DLSAPLength,
  1332.     kEnetTSDU                    = 1514,                            /* The TSDU for ethernet.*/
  1333.     kTokenRingTSDU                = 4458,                            /* The TSDU for TokenRing.*/
  1334.     kFDDITSDU                    = 4458,                            /* The TSDU for FDDI. */
  1335.     k8022SAPLength                = 1,
  1336.     k8022BasicHeaderLength        = 3,                            /* define the length of the header portion of an 802.2 packet.*/
  1337.                                                                 /* = SSAP+DSAP+ControlByte*/
  1338.     k8022SNAPHeaderLength        = k8022SNAPLength + k8022BasicHeaderLength
  1339. };
  1340.  
  1341. /*******************************************************************************
  1342. ** Address Types recognized by the Enet DLPI
  1343. ********************************************************************************/
  1344.  
  1345. typedef UInt32 EAddrType;
  1346. enum {
  1347.     keaStandardAddress            = 0,
  1348.     keaMulticast                = 1,
  1349.     keaBroadcast                = 2,
  1350.     keaBadAddress                = 3,
  1351.     keaRawPacketBit                = 0x80000000,
  1352.     keaTimeStampBit                = 0x40000000
  1353. };
  1354.  
  1355. /* Packet Header Structures*/
  1356.  
  1357.  
  1358. struct EnetPacketHeader {
  1359.     UInt8                             fDestAddr[6];
  1360.     UInt8                             fSourceAddr[6];
  1361.     UInt16                             fProto;
  1362. };
  1363. typedef struct EnetPacketHeader            EnetPacketHeader;
  1364.  
  1365. struct T8022Header {
  1366.     UInt8                             fDSAP;
  1367.     UInt8                             fSSAP;
  1368.     UInt8                             fCtrl;
  1369. };
  1370. typedef struct T8022Header                T8022Header;
  1371.  
  1372. struct T8022SNAPHeader {
  1373.     UInt8                             fDSAP;
  1374.     UInt8                             fSSAP;
  1375.     UInt8                             fCtrl;
  1376.     UInt8                             fSNAP[5];
  1377. };
  1378. typedef struct T8022SNAPHeader            T8022SNAPHeader;
  1379.  
  1380. struct T8022FullPacketHeader {
  1381.     EnetPacketHeader                 fEnetPart;
  1382.     T8022SNAPHeader                 f8022Part;
  1383. };
  1384. typedef struct T8022FullPacketHeader    T8022FullPacketHeader;
  1385. /* Define the lengths of the structures above*/
  1386. enum {
  1387.     kT8022HeaderLength            = 3,
  1388.     kT8022SNAPHeaderLength        = 3 + k8022SNAPLength,
  1389.     kT8022FullPacketHeaderLength = kEnetPacketHeaderLength + kT8022SNAPHeaderLength
  1390. };
  1391.  
  1392. /* ***** Serial ******/
  1393.  
  1394. /* Module Definitions*/
  1395.  
  1396. /* XTI Level*/
  1397.  
  1398. enum {
  1399.     COM_SERIAL                    = FOUR_CHAR_CODE('SERL')
  1400. };
  1401.  
  1402. /* Version Number*/
  1403.  
  1404.  
  1405. #define kSerialABVersion    "1.1.1"
  1406.  
  1407. /* Module Names*/
  1408.  
  1409.  
  1410. #define kSerialABName        "serialAB"
  1411. #define kSerialName            "serial"
  1412. #define kSerialPortAName    "serialA"
  1413. #define kSerialPortBName    "serialB"
  1414.  
  1415. enum {
  1416.     kSerialABModuleID            = 7200
  1417. };
  1418.  
  1419. enum {
  1420.     kOTSerialFramingAsync        = 0x01,                            /* Support Async serial mode             */
  1421.     kOTSerialFramingHDLC        = 0x02,                            /* Support HDLC synchronous serial mode    */
  1422.     kOTSerialFramingSDLC        = 0x04,                            /* Support SDLC synchronous serial mode    */
  1423.     kOTSerialFramingAsyncPackets = 0x08                            /* Support Async "packet" serial mode    */
  1424. };
  1425.  
  1426. /* IOCTL Calls for Serial Drivers*/
  1427.  
  1428. enum {
  1429.     I_SetSerialDTR                = ((MIOC_SRL << 8) | 0),        /* Set DTR (0 = off, 1 = on)*/
  1430.     kOTSerialSetDTROff            = 0,
  1431.     kOTSerialSetDTROn            = 1,
  1432.     I_SetSerialBreak            = ((MIOC_SRL << 8) | 1),        /* Send a break on the line - kOTSerialSetBreakOff = off, kOTSerialSetBreakOn = on,*/
  1433.                                                                 /* Any other number is the number of milliseconds to leave break on, then*/
  1434.                                                                 /* auto shutoff*/
  1435.     kOTSerialSetBreakOn            = 0xFFFFFFFF,
  1436.     kOTSerialSetBreakOff        = 0,
  1437.     I_SetSerialXOffState        = ((MIOC_SRL << 8) | 2),        /* Force XOFF state - 0 = Unconditionally clear XOFF state, 1 = unconditionally set it*/
  1438.     kOTSerialForceXOffTrue        = 1,
  1439.     kOTSerialForceXOffFalse        = 0,
  1440.     I_SetSerialXOn                = ((MIOC_SRL << 8) | 3),        /* Send an XON character, 0 = send only if in XOFF state, 1 = send always*/
  1441.     kOTSerialSendXOnAlways        = 1,
  1442.     kOTSerialSendXOnIfXOffTrue    = 0,
  1443.     I_SetSerialXOff                = ((MIOC_SRL << 8) | 4),        /* Send an XOFF character, 0 = send only if in XON state, 1 = send always*/
  1444.     kOTSerialSendXOffAlways        = 1,
  1445.     kOTSerialSendXOffIfXOnTrue    = 0
  1446. };
  1447.  
  1448. /* Option Management for Serial Drivers*/
  1449.  
  1450. /*
  1451.    These options are all 4-byte values.
  1452.    BaudRate is the baud rate.
  1453.    DataBits is the number of data bits.
  1454.    StopBits is the number of stop bits times 10.
  1455.    Parity is an enum
  1456. */
  1457.  
  1458. enum {
  1459.     SERIAL_OPT_BAUDRATE            = 0x0100,                        /* UInt32    */
  1460.     SERIAL_OPT_DATABITS            = 0x0101,                        /* UInt32    */
  1461.     SERIAL_OPT_STOPBITS            = 0x0102,                        /* UInt32 10, 15 or 20 for 1, 1.5 or 2    */
  1462.     SERIAL_OPT_PARITY            = 0x0103,                        /* UInt32    */
  1463.     SERIAL_OPT_STATUS            = 0x0104,                        /* UInt32 */
  1464.                                                                 /* The "Status" option is a 4-byte value option that is ReadOnly*/
  1465.                                                                 /* It returns a bitmap of the current serial status*/
  1466.     SERIAL_OPT_HANDSHAKE        = 0x0105,                        /* UInt32 */
  1467.                                                                 /* The "Handshake" option defines what kind of handshaking the serial port*/
  1468.                                                                 /* will do for line flow control.  The value is a 32-bit value defined by*/
  1469.                                                                 /* the function or macro SerialHandshakeData below.*/
  1470.                                                                 /* For no handshake, or CTS handshake, the onChar and offChar parameters*/
  1471.                                                                 /* are ignored.*/
  1472.     SERIAL_OPT_RCVTIMEOUT        = 0x0106,                        /* The "RcvTimeout" option defines how long the receiver should wait before delivering*/
  1473.                                                                 /* less than the RcvLoWat number of characters.  If RcvLoWat is 0, then the RcvTimeout*/
  1474.                                                                 /* is how long a gap to wait for before delivering characters.  This parameter is advisory,*/
  1475.                                                                 /* and serial drivers are free to deliver data whenever they deem it convenient.  For instance,*/
  1476.                                                                 /* many serial drivers will deliver data whenever 64 bytes have been received, since 64 bytes*/
  1477.                                                                 /* is the smallest STREAMS buffer size. Keep in mind that timeouts are quantized, so be sure to*/
  1478.                                                                 /* look at the return value of the option to determine what it was negotiated to.*/
  1479.     SERIAL_OPT_ERRORCHARACTER    = 0x0107,                        /* This option defines how characters with parity errors are handled.*/
  1480.                                                                 /* A 0 value will disable all replacement.  A single character value in the low*/
  1481.                                                                 /* byte designates the replacement character.  When characters are received with a */
  1482.                                                                 /* parity error, they are replaced by this specified character.  If a valid incoming*/
  1483.                                                                 /* character matches the replacement character, then the received character's msb is*/
  1484.                                                                 /* cleared. For this situation, the alternate character is used, if specified in bits*/
  1485.                                                                 /* 8 through 15 of the option long, with 0xff being place in bits 16 through 23.*/
  1486.                                                                 /* Whenever a valid character is received that matches the first replacement character,*/
  1487.                                                                 /* it is replaced with this alternate character.*/
  1488.     SERIAL_OPT_EXTCLOCK            = 0x0108,                        /* The "ExtClock" requests an external clock.  A 0-value turns off external clocking.*/
  1489.                                                                 /* Any other value is a requested divisor for the external clock.  Be aware that*/
  1490.                                                                 /* not all serial implementations support an external clock, and that not all*/
  1491.                                                                 /* requested divisors will be supported if it does support an external clock.*/
  1492.     SERIAL_OPT_BURSTMODE        = 0x0109,                        /* The "BurstMode" option informs the serial driver that it should continue looping,*/
  1493.                                                                 /* reading incoming characters, rather than waiting for an interrupt for each character.*/
  1494.                                                                 /* This option may not be supported by all Serial driver*/
  1495.     SERIAL_OPT_DUMMY            = 0x010A                        /* placeholder*/
  1496. };
  1497.  
  1498.  
  1499. typedef UInt32 ParityOptionValues;
  1500. enum {
  1501.     kOTSerialNoParity            = 0,
  1502.     kOTSerialOddParity            = 1,
  1503.     kOTSerialEvenParity            = 2
  1504. };
  1505.  
  1506. enum {
  1507.     kOTSerialSwOverRunErr        = 0x01,
  1508.     kOTSerialBreakOn            = 0x08,
  1509.     kOTSerialParityErr            = 0x10,
  1510.     kOTSerialOverrunErr            = 0x20,
  1511.     kOTSerialFramingErr            = 0x40,
  1512.     kOTSerialXOffSent            = 0x00010000,
  1513.     kOTSerialDTRNegated            = 0x00020000,
  1514.     kOTSerialCTLHold            = 0x00040000,
  1515.     kOTSerialXOffHold            = 0x00080000,
  1516.     kOTSerialOutputBreakOn        = 0x01000000
  1517. };
  1518.  
  1519. enum {
  1520.     kOTSerialXOnOffInputHandshake = 1,                            /* Want XOn/XOff handshake for incoming characters    */
  1521.     kOTSerialXOnOffOutputHandshake = 2,                            /* Want XOn/XOff handshake for outgoing characters    */
  1522.     kOTSerialCTSInputHandshake    = 4,                            /* Want CTS handshake for incoming characters        */
  1523.     kOTSerialDTROutputHandshake    = 8                                /* Want DTR handshake for outoing characters        */
  1524. };
  1525.  
  1526.  
  1527. #ifdef __cplusplus
  1528.  
  1529.     inline UInt32 OTSerialHandshakeData(UInt16 type, UInt8 onChar, UInt8 offChar)
  1530.     {
  1531.         return (((UInt32)type) << 16) | (((UInt32)onChar) << 8) | offChar;
  1532.     }
  1533.  
  1534. #else
  1535.  
  1536.     #define OTSerialHandshakeData(type, onChar, offChar)    \
  1537.         ((((UInt32)type) << 16) | (((UInt32)onChar) << 8) | offChar)
  1538.     
  1539. #endif
  1540.  
  1541.  
  1542. #ifdef __cplusplus
  1543.  
  1544. inline UInt32 OTSerialSetErrorCharacter(UInt8 rep)
  1545. {
  1546.     return (UInt32)rep & 0x000000ff;
  1547. }
  1548.  
  1549. inline UInt32 OTSerialSetErrorCharacterWithAlternate(UInt8 rep, UInt8 alternate)
  1550. {
  1551.     return (((rep & 0xff) | ((alternate & 0xff) << 8)) | 0x80000000L);
  1552. }
  1553.  
  1554. #else
  1555.  
  1556. #define OTSerialSetErrorCharacter(rep)    \
  1557.     ((rep) & 0xff)
  1558.  
  1559. #define OTSerialSetErrorCharacterWithAlternate(rep, alternate)    \
  1560.     ((((rep) & 0xff) | (((alternate) & 0xff) << 8)) | 0x80000000L)
  1561.  
  1562. #endif
  1563.  
  1564. /* Default attributes for the serial ports*/
  1565.  
  1566. enum {
  1567.     kOTSerialDefaultBaudRate    = 19200,
  1568.     kOTSerialDefaultDataBits    = 8,
  1569.     kOTSerialDefaultStopBits    = 10,
  1570.     kOTSerialDefaultParity        = kOTSerialNoParity,
  1571.     kOTSerialDefaultHandshake    = 0,
  1572.     kOTSerialDefaultOnChar        = ('Q' & 0xFFFFFFBF),
  1573.     kOTSerialDefaultOffChar        = ('S' & 0xFFFFFFBF),
  1574.     kOTSerialDefaultSndBufSize    = 1024,
  1575.     kOTSerialDefaultRcvBufSize    = 1024,
  1576.     kOTSerialDefaultSndLoWat    = 96,
  1577.     kOTSerialDefaultRcvLoWat    = 1,
  1578.     kOTSerialDefaultRcvTimeout    = 10
  1579. };
  1580.  
  1581. /* ***** ISDN ******/
  1582.  
  1583. /* Module Definitions*/
  1584.  
  1585. /* XTI Level*/
  1586.  
  1587. enum {
  1588.     COM_ISDN                    = FOUR_CHAR_CODE('ISDN')
  1589. };
  1590.  
  1591. /* Module Names*/
  1592.  
  1593. #define kISDNName        "isdn"
  1594. enum {
  1595.     kISDNModuleID                = 7300
  1596. };
  1597.  
  1598.  
  1599. /* ISDN framing methods, set using the I_OTSetFramingType IOCTL*/
  1600.  
  1601. enum {
  1602.     kOTISDNFramingTransparentSupported = 0x0010,                /* Support Transparent mode         */
  1603.     kOTISDNFramingHDLCSupported    = 0x0020,                        /* Support HDLC Synchronous mode     */
  1604.     kOTISDNFramingV110Supported    = 0x0040,                        /* Support V.110 Asynchronous mode     */
  1605.     kOTISDNFramingV14ESupported    = 0x0080                        /* Support V.14 Asynchronous mode     */
  1606. };
  1607.  
  1608. /* Miscellaneous equates*/
  1609.  
  1610. /* Disconnect reason codes (from Q.931)*/
  1611.  
  1612. enum {
  1613.     kOTISDNUnallocatedNumber    = 1,
  1614.     kOTISDNNoRouteToSpecifiedTransitNetwork = 2,
  1615.     kOTISDNNoRouteToDestination    = 3,
  1616.     kOTISDNChannelUnacceptable    = 6,
  1617.     kOTISDNNormal                = 16,
  1618.     kOTISDNUserBusy                = 17,
  1619.     kOTISDNNoUserResponding        = 18,
  1620.     kOTISDNNoAnswerFromUser        = 19,
  1621.     kOTISDNCallRejected            = 21,
  1622.     kOTISDNNumberChanged        = 22,
  1623.     kOTISDNNonSelectedUserClearing = 26,
  1624.     kOTISDNDestinationOutOfOrder = 27,
  1625.     kOTISDNInvalidNumberFormat    = 28,
  1626.     kOTISDNFacilityRejected        = 29,
  1627.     kOTISDNNormalUnspecified    = 31,
  1628.     kOTISDNNoCircuitChannelAvailable = 34,
  1629.     kOTISDNNetworkOutOfOrder    = 41,
  1630.     kOTISDNSwitchingEquipmentCongestion = 42,
  1631.     kOTISDNAccessInformationDiscarded = 43,
  1632.     kOTISDNRequestedCircuitChannelNotAvailable = 44,
  1633.     kOTISDNResourceUnavailableUnspecified = 45,
  1634.     kOTISDNQualityOfServiceUnvailable = 49,
  1635.     kOTISDNRequestedFacilityNotSubscribed = 50,
  1636.     kOTISDNBearerCapabilityNotAuthorized = 57,
  1637.     kOTISDNBearerCapabilityNotPresentlyAvailable = 58,
  1638.     kOTISDNCallRestricted        = 59,
  1639.     kOTISDNServiceOrOptionNotAvilableUnspecified = 63,
  1640.     kOTISDNBearerCapabilityNotImplemented = 65,
  1641.     kOTISDNRequestedFacilityNotImplemented = 69,
  1642.     kOTISDNOnlyRestrictedDigitalBearer = 70,
  1643.     kOTISDNServiceOrOptionNotImplementedUnspecified = 79,
  1644.     kOTISDNCallIdentityNotUsed    = 83,
  1645.     kOTISDNCallIdentityInUse    = 84,
  1646.     kOTISDNNoCallSuspended        = 85,
  1647.     kOTISDNCallIdentityCleared    = 86,
  1648.     kOTISDNIncompatibleDestination = 88,
  1649.     kOTISDNInvalidTransitNetworkSelection = 91,
  1650.     kOTISDNInvalidMessageUnspecified = 95,
  1651.     kOTISDNMandatoryInformationElementIsMissing = 96,
  1652.     kOTISDNMessageTypeNonExistentOrNotImplemented = 97,
  1653.     kOTISDNInterworkingUnspecified = 127
  1654. };
  1655.  
  1656. /* OTISDNAddress*/
  1657.  
  1658. /*
  1659.    The OTISDNAddress has the following format:
  1660.    "xxxxxx*yy"
  1661.    where 'x' is the phone number and 'y' is the sub address (if available
  1662.    in the network. The characters are coded in ASCII (IA5), and valid
  1663.    characters are: '0'-'9','#','*'.
  1664.    The max length of the each phone number is 21 characters (?) and the max
  1665.    subaddress length is network dependent.
  1666.    When using bonded channels the phone numbers are separated by '&'.
  1667.    The X.25 user data is preceded by '@'.
  1668. */
  1669.  
  1670. #ifndef AF_ISDN /* might conflict with BSD headers */ 
  1671. enum {
  1672.     AF_ISDN                        = 0x2000
  1673. };
  1674.  
  1675. #endif
  1676. enum {
  1677.     kOTISDNMaxPhoneSize            = 32,
  1678.     kOTISDNMaxSubSize            = 4
  1679. };
  1680.  
  1681.  
  1682. struct OTISDNAddress {
  1683.     OTAddressType                     fAddressType;
  1684.     UInt16                             fPhoneLength;
  1685.     char                             fPhoneNumber[37];
  1686. };
  1687. typedef struct OTISDNAddress            OTISDNAddress;
  1688. /* IOCTL Calls for ISDN*/
  1689. /* ISDN shares the same ioctl space as serial.*/
  1690.  
  1691. enum {
  1692.     MIOC_ISDN                    = 'U'                            /* ISDN ioctl() cmds */
  1693. };
  1694.  
  1695. enum {
  1696.     I_OTISDNAlerting            = ((MIOC_ISDN << 8) | 100),        /* Send or receive an ALERTING message*/
  1697.     I_OTISDNSuspend                = ((MIOC_ISDN << 8) | 101),        /* Send a SUSPEND message*/
  1698.                                                                 /* The parameter is the Call Identity (Maximum 8 octets)*/
  1699.     I_OTISDNSuspendAcknowledge    = ((MIOC_ISDN << 8) | 102),        /* Receive a SUSPEND ACKNOWLEDGE message*/
  1700.     I_OTISDNSuspendReject        = ((MIOC_ISDN << 8) | 103),        /* Receive a SUSPEND REJECT message*/
  1701.     I_OTISDNResume                = ((MIOC_ISDN << 8) | 104),        /* Send a RESUME message*/
  1702.                                                                 /* The parameter is the Call Identity (Maximum 8 octets)*/
  1703.     I_OTISDNResumeAcknowledge    = ((MIOC_ISDN << 8) | 105),        /* Receive a RESUME ACKNOWLEDGE message*/
  1704.     I_OTISDNResumeReject        = ((MIOC_ISDN << 8) | 106),        /* Receive a RESUME REJECT message*/
  1705.     I_OTISDNFaciltity            = ((MIOC_ISDN << 8) | 107)        /* Send or receive a FACILITY message*/
  1706. };
  1707.  
  1708. /* Connect user data size*/
  1709.  
  1710. enum {
  1711.     kOTISDNMaxUserDataSize        = 32
  1712. };
  1713.  
  1714. /* Option management calls for ISDN*/
  1715.  
  1716. enum {
  1717.     ISDN_OPT_COMMTYPE            = 0x0200,
  1718.     ISDN_OPT_FRAMINGTYPE        = 0x0201,
  1719.     ISDN_OPT_56KADAPTATION        = 0x0202
  1720. };
  1721.  
  1722. /* For ISDN_OPT_COMMTYPE...*/
  1723.  
  1724. enum {
  1725.     kOTISDNTelephoneALaw        = 1,                            /* G.711 A-law                         */
  1726.     kOTISDNTelephoneMuLaw        = 26,                            /* G.711 .-law                         */
  1727.     kOTISDNDigital64k            = 13,                            /* unrestricted digital (default)     */
  1728.     kOTISDNDigital56k            = 37,                            /* user rate 56Kb/s                 */
  1729.     kOTISDNVideo64k                = 41,                            /* video terminal at 64Kb/s         */
  1730.     kOTISDNVideo56k                = 42                            /* video terminal at 56Kb/s         */
  1731. };
  1732.  
  1733. /* For ISDN_OPT_FRAMINGTYPE...*/
  1734.  
  1735. enum {
  1736.     kOTISDNFramingTransparent    = 0x0010,                        /* Transparent mode                 */
  1737.     kOTISDNFramingHDLC            = 0x0020,                        /* HDLC synchronous mode (default)    */
  1738.     kOTISDNFramingV110            = 0x0040,                        /* V.110 asynchronous mode             */
  1739.     kOTISDNFramingV14E            = 0x0080                        /* V.14E asynchronous mode            */
  1740. };
  1741.  
  1742. /* For ISDN_OPT_56KADAPTATION...*/
  1743.  
  1744. enum {
  1745.     kOTISDNNot56KAdaptation        = false,                        /* not 56K Adaptation (default)        */
  1746.     kOTISDN56KAdaptation        = true                            /* 56K Adaptation                    */
  1747. };
  1748.  
  1749. /* Default options, you do not need to set these*/
  1750.  
  1751. enum {
  1752.     kOTISDNDefaultCommType        = kOTISDNDigital64k,
  1753.     kOTISDNDefaultFramingType    = kOTISDNFramingHDLC,
  1754.     kOTISDNDefault56KAdaptation    = kOTISDNNot56KAdaptation
  1755. };
  1756.  
  1757.  
  1758. #if defined(__MWERKS__) && TARGET_CPU_68K
  1759.     #pragma pop
  1760. #endif
  1761.  
  1762.  
  1763. #if PRAGMA_STRUCT_ALIGN
  1764.     #pragma options align=reset
  1765. #elif PRAGMA_STRUCT_PACKPUSH
  1766.     #pragma pack(pop)
  1767. #elif PRAGMA_STRUCT_PACK
  1768.     #pragma pack()
  1769. #endif
  1770.  
  1771. #ifdef PRAGMA_IMPORT_OFF
  1772. #pragma import off
  1773. #elif PRAGMA_IMPORT
  1774. #pragma import reset
  1775. #endif
  1776.  
  1777. #ifdef __cplusplus
  1778. }
  1779. #endif
  1780.  
  1781. #endif /* __OPENTRANSPORTPROVIDERS__ */
  1782.  
  1783.